public class Test02 {
    public static int find(int[] numbers){
        int[] count = new int[1000];
        for(int x : numbers){
            count[x]++;
            if(count[x] >1){
                return x;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        int[] numbers = new int[1000];
        for (int i = 0; i < 999; i++) {
            numbers[i] = i;
        }
        numbers[999] = 666;
        int i = find(numbers);
        System.out.println(i);
    }
}
